{{ if .IsNamedParams }}
  {{ $.Scratch.Add "c-title" (.Get "title") }}
  {{ $.Scratch.Add "c-language" (lower (.Get "lang")) }}
  {{ $.Scratch.Add "c-url" (.Get "url") }}
  {{ $.Scratch.Add "c-link-text" (.Get "link-text") }}
{{ else }}
  {{ if ge (len .Params) 1 }}
    {{ $.Scratch.Add "c-title" (.Get 0) }}
  {{ end }}
  {{ if ge (len .Params) 2 }}
    {{ $.Scratch.Add "c-language" (lower (.Get 1)) }}
  {{ end }}
  {{ if ge (len .Params) 3 }}
    {{ $.Scratch.Add "c-url" (.Get 2) }}
  {{ end }}
  {{ if ge (len .Params) 4 }}
    {{ $.Scratch.Add "c-link-text" (.Get 3) }}
  {{ end }}
{{ end }}
{{ $trimmedContent := trim .Inner "\n" }}
<figure class="highlight {{ $.Scratch.Get "c-language" }} language-{{ with ($.Scratch.Get "c-language") }}{{ . }}{{ end }}">
  <figcaption>
    {{ if and (($.Scratch.Get "c-url") ($.Scratch.Get "c-title")) }}
      <span>{{ $.Scratch.Get "c-title" }}</span><a href="{{ ($.Scratch.Get "c-url") | safeURL }}" target="_blank" rel="external">{{ $.Scratch.Get "c-link-text" | default ($.Scratch.Get "c-title") }}</a>
    {{ else if $.Scratch.Get "c-title" }}
      <span>{{ $.Scratch.Get "c-title" }}</span>
    {{ end }}
  </figcaption>
  <table>
    <tbody>
      <tr>
        <td class="gutter">
          <pre>{{ range $index,$value := (split $trimmedContent "\n") }}<span class="line">{{ add $index 1 }}</span><br>{{ end }}</pre>
        </td>
        <td class="code">
          <pre class="code-highlight language-{{ $.Scratch.Get "c-language" }}"><code class="{{ $.Scratch.Get "c-language" }}">{{ $trimmedContent }}</code></pre>
        </td>
      </tr>
    </tbody>
  </table>
</figure>